
import Home from "@/pages/home";
import Login from "@/pages/login";
import Register from "@/pages/register";
import Search from "@/pages/search";
import ShopCar from "@/pages/shop_car";
import AddCar from "@/pages/shop_car/add";
import Trade from "@/pages/trade"
import Pay from "@/pages/pay"
import PaySuccess from "@/pages/pay_success"
import Center from "@/pages/center"

//引用文件
import MyOrder from "@/pages/center/my_order"
import GroupOrder from "@/pages/center/group_order"

export default [
  { path: "/center", redirect: "/center/myorder", meta: { show: true } },  //重定向
  { path: "/", redirect: "/home", meta: { show: true } },
  { path: "/home", component: Home, meta: { show: true } },
  {
    name: "detail",
    path: "/detail/:skuId?",
    component: () => import("@/pages/detail"),  //路由懒加载
    meta: { show: true },
  },
  { path: "/login", component: Login, meta: { show: false } },
  { path: "/register", component: Register, meta: { show: false } },
  {
    name: "search",
    path: "/search/:keyword?",
    component: Search,
    meta: { show: true },
  },
  {
    name: "addCar",
    path: "/addCar/:skuNum?",
    component: AddCar,
    meta: { show: true },
  },
  {
    name: "shopCar",
    path: "/shopCar",
    component: ShopCar,
    meta: { show: true },
  },
  {
    name: "trade",
    path: "/trade",
    component: Trade,
    meta: { show: true },
    beforeEnter: (to, from, next) => { // 在单个路由的独享守卫逻辑,路由独享的守卫
      if (from.path === '/shopCar') {
        next()
      } else {
        next(from); //会跳转到根路由
      }
    }
  },
  {
    name: "pay",
    path: "/pay",
    component: Pay,
    meta: { show: true },
    beforeEnter: (to, from, next) => { // 在单个路由的独享守卫逻辑,路由独享的守卫
      if (from.path === '/trade') {
        next()
      } else {
        next(from);
      }
    }
  },
  {
    name: "paySuccess",
    path: "/paySuccess",
    component: PaySuccess,
    meta: { show: true },
  },
  {
    name: "center",
    path: "/center",
    component: Center,
    meta: { show: true },
    children: [  //二级路由
      {
        path: 'myOrder',
        component: MyOrder,
      },
      {
        path: 'groupOrder',
        component: GroupOrder,
      }
    ]
  },
  {
    path: '/communication',
    component: () => import('@/pages/Communication/Communication'),
    children: [
      {
        path: 'event',
        component: () => import('@/pages/Communication/EventTest/EventTest'),
        meta: {
         show: false
        },
      },
      {
        path: 'model',
        component: () => import('@/pages/Communication/ModelTest/ModelTest'),
        meta: {
            show: false
        },
      },
      {
        path: 'sync',
        component: () => import('@/pages/Communication/SyncTest/SyncTest'),
        meta: {
            show: false
        },
      },
      {
        path: 'attrs-listeners',
        component: () => import('@/pages/Communication/AttrsListenersTest/AttrsListenersTest'),
        meta: {
            show: false
        },
      },
      {
        path: 'children-parent',
        component: () => import('@/pages/Communication/ChildrenParentTest/ChildrenParentTest'),
        meta: {
            show: false
        },
      },
      {
        path: 'scope-slot',
        component: () => import('@/pages/Communication/ScopeSlotTest/ScopeSlotTest'),
        meta: {
            show: false
        },
      }
    ],
  },




];
